package com.lfm;

public class Thread01 {
    public static void main(String[] args) throws InterruptedException {
        //创建Cat对象， 可以当作线程使用
        Cat cat = new Cat();
        cat.start();//启动线程
        //当main线程启动一个子线程Thread-0后 , 主线程不会阻塞. 会继续执行

        System.out.println("主线程继续执行"  + Thread.currentThread().getName());//名字main
        for (int i = 0; i < 60; i ++) {
            System.out.println("主线程i =" + i);
            //让主线程休眠
            Thread.sleep(1000);
        }

    }
}


class Cat extends Thread {
    int times = 0;
    @Override
    public void run() {// 重写run方法
        while (true) {
            System.out.println("测试线程" + (++times));
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
            if (times == 80) {
                break;
            }
        }

    }

}
